package com.xianbeiying.app.ckgl.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xianbeiying.app.ckgl.R;

import java.util.ArrayList;

/**
 * 风机手动自动选择设备数据适配
 */
public class VarbGridViewAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<String> arrayList;
    private String type;

    public VarbGridViewAdapter(Context context, ArrayList<String> arrayList, String type) {
        this.context = context;
        this.arrayList = arrayList;
        this.type = type;
    }

    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int position) {
        return getItem(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_va_choice, parent, false);
            holder = new ViewHolder();
            holder.va_choice_number = (TextView) convertView.findViewById(R.id.va_choice_number);
            holder.tv_cp_type = (TextView) convertView.findViewById(R.id.tv_cp_type);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tv_cp_type.setText(arrayList.get(position));
        return convertView;
    }

    private class ViewHolder {
        TextView va_choice_number;
        TextView tv_cp_type;
    }
}
